package chap3_9;

import java.util.Scanner;

public class Exer3_9_9 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入钱数：");
        int n = input.nextInt();
        int i = 0, j = 0, k = 0, l = 0, m = 0, p = 0, q = 0;
        for (i = 0; i <= n; i++) {
            if (n == i) {
                System.out.println("1元的数目" + i);
                continue;
            }
            for (j = 0; j <= n / 2; j++) {
                if (i + 2 * j == n) {
                    System.out.print("1元的数目" + i+",");
                    System.out.print("2元的数目" + j);
                    System.out.println();
                    continue;
                }
                for (k = 0; k <= n / 5; k++) {
                    if (i + 2 * j + 5 * k == n) {
                        System.out.print("1元的数目" + i+",");
                        System.out.print("2元的数目" + j+",");
                        System.out.print("5元的数目" + k+",");
                        System.out.println();
                        continue;
                    }
                    for (l = 0; l <= n / 10; l++) {
                        if (i + 2 * j + 5 * k + 10 * l == n) {
                            System.out.print("1元的数目" + i+"，");
                            System.out.print("2元的数目" + j+"，");
                            System.out.print("5元的数目" + k+"，");
                            System.out.print("10元的数目" + l);
                            System.out.println();
                            continue;
                        }
                        for (m = 0; m <= n / 20; m++) {
                            if (i + 2 * j + 5 * k + 10 * l + 20 * m == n) {
                                System.out.print("1元的数目" + i+"，");
                                System.out.print("2元的数目" + j+"，");
                                System.out.print("5元的数目" + k+"，");
                                System.out.print("10元的数目" + l+"，");
                                System.out.print("20元的数目" + m);
                                System.out.println();
                                continue;
                            }
                            for (p = 0; p <= n / 50; p++) {
                                if (i + 2 * j + 5 * k + 10 * l + 20 * m + 50 * p == n) {
                                    System.out.print("1元的数目" + i+"，");
                                    System.out.print("2元的数目" + j+"，");
                                    System.out.print("5元的数目" + k+"，");
                                    System.out.print("10元的数目" + l+"，");
                                    System.out.print("20元的数目" + m+",");
                                    System.out.print("50元的数目" + p);
                                    System.out.println();
                                    continue;
                                }
                                for (q = 0; q <= n / 100; q++) {
                                    if (i + 2 * j + 5 * k + 10 * n + 20 * m + 50 * p + 100 * q == n) {
                                        System.out.print("1元的数目" + i+"，");
                                        System.out.print("2元的数目" + j+"，");
                                        System.out.print("5元的数目" + k+"，");
                                        System.out.print("10元的数目" + l+"，");
                                        System.out.print("20元的数目" + m+",");
                                        System.out.print("50元的数目" + p+",");
                                        System.out.print("100元的数目" + q);
                                        System.out.println();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}


